package guoanmaker.operator.business.repository;

import guoanmaker.operator.business.model.OperatorCouponPage;
import guoanmaker.operator.business.model.OperatorNewsList;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;
import java.util.Optional;

/**
 * 
* @ClassName: OperatorNewsListRepository
* @Description:TODO (这里用一句话描述这个类的作用) 
* @author lihongyu
* @date 2017年8月30日 下午6:00:40 
*  
 */
public interface OperatorNewsListRepository extends JpaRepository<OperatorNewsList, String>, JpaSpecificationExecutor<OperatorNewsList> {
//	@Query("select u from OperatorUser u left join fetch u.roles r where u.username=:username")
//    public Optional<OperatorUser> findByUsername(@Param("username") String username);

    @Query("select n from OperatorNewsList n where n.status=1")
    Page<OperatorNewsList> getTieleAndUrl(Pageable pageable);
    
    @Query("select n from OperatorNewsList n where n.newsType=:newsType")
    List<OperatorNewsList> getNews(@Param("newsType") String newsType);
    
    @Query("select n from OperatorNewsList n where n.status=1")
    List<OperatorNewsList> getNewList();
}